home *** CD-ROM | disk | FTP | other *** search
- package java.net;
-
- import java.io.FileDescriptor;
- import java.io.IOException;
-
- public final class ServerSocket {
- SocketImpl impl;
- private static SocketImplFactory factory;
-
- ServerSocket() throws IOException {
- this.impl = (SocketImpl)(factory != null ? factory.createSocketImpl() : new PlainSocketImpl());
- }
-
- public ServerSocket(int var1) throws IOException {
- this(var1, 50);
- }
-
- public ServerSocket(int var1, int var2) throws IOException {
- this();
- SecurityManager var3 = System.getSecurityManager();
- if (var3 != null) {
- var3.checkListen(var1);
- }
-
- this.impl.create(true);
- this.impl.bind(InetAddress.anyLocalAddress, var1);
- this.impl.listen(var2);
- }
-
- public InetAddress getInetAddress() {
- return this.impl.getInetAddress();
- }
-
- public int getLocalPort() {
- return this.impl.getLocalPort();
- }
-
- public Socket accept() throws IOException {
- Socket var1 = new Socket();
-
- try {
- var1.impl.address = new InetAddress();
- var1.impl.fd = new FileDescriptor();
- this.impl.accept(var1.impl);
- SecurityManager var2 = System.getSecurityManager();
- if (var2 != null) {
- var2.checkAccept(var1.impl.getInetAddress().getHostName(), var1.impl.getPort());
- }
-
- return var1;
- } catch (IOException var3) {
- var1.close();
- throw var3;
- } catch (SecurityException var4) {
- var1.close();
- throw var4;
- }
- }
-
- public void close() throws IOException {
- this.impl.close();
- }
-
- public String toString() {
- return "ServerSocket[addr=" + this.impl.getInetAddress() + ",port=" + this.impl.getPort() + ",localport=" + this.impl.getLocalPort() + "]";
- }
-
- public static synchronized void setSocketFactory(SocketImplFactory var0) throws IOException {
- if (factory != null) {
- throw new SocketException("factory already defined");
- } else {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkSetFactory();
- }
-
- factory = var0;
- }
- }
- }
-